<%--
  Created by IntelliJ IDEA.
  User: yangpengjie
  Date: 2022/12/26
  Time: 16:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
  <%@include file="/jsp/student/common_css.jsp"%>
  <script src="${pageContext.request.contextPath}/style/js/jquery-3.5.1.js"></script>
</head>
<html>
<div class="col-xl-6 col-lg-6">
  <div class="card">
    <div class="card-header">
      <h4>编辑用户</h4>
    </div>
    <div class="card-body">
      <form name="frm" id="frm">
        <div class="row">
          <div class="col-xl-6 col-lg-6">
            <div class="form-group">
              <%--                for="text-input"--%>
              <label  class="col-form-label">名字</label>
              <input name="name" id="name" class="form-control" type="text" placeholder="" value="${data.userName}" readonly="readonly">
            </div>
          </div>
          <div class="col-xl-6 col-lg-6">
            <div class="form-group">
              <label  class="col-form-label">联系方式</label>
              <input name="studentId" id="student_id" class="form-control" type="text" placeholder="" value="${data.phone}">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-xl-6 col-lg-6">
            <div class="form-group">
              <label  class="col-form-label">密码</label>
              <input name="phone" id="phone" class="form-control" type="text" placeholder="" value="${data.password}">
            </div>
          </div>
        </div>
        <div class="form-group mb-0">
          <div class="checkbox mb-3">
            <input id="checkbox1" type="checkbox">
            <label for="checkbox1">check me out</label>
          </div>
        </div>
        <div class="form-group mb-0">
          <input type="hidden" name="id" value="${data.id}">
          <%--            <input type="button" onclick="doMessage()" value="提交">--%>
          <button onclick="doEdit()" class="btn btn-primary squer-btn mt-2 mr-2" type="button">Submit</button>
        </div>
      </form>
    </div>
  </div>
</div>
<%@include file="/jsp/student/common_js.jsp"%>
</html>

<script>
  function doEdit(){
    $.ajax(
            {
              <%--url: "${pageContext.request.contextPath}/studentm",--%>
              url:"${pageContext.request.contextPath}/admin?method=doEditStudentRegister",
              type: "post",
              data: $("#frm").serialize(),
              async: false,  //设置同步
              success: function (response) {
                if (response == 'ok') {
                  alert("用户信息修改成功");
                  setTimeout("window.location.href='/admin?method=StudentRegisterMain'", 1000)
                } else{
                  alert("编辑用户失败失败，请检查!");
                }
              }
            }
    )
  }
</script>